//
//  RecommendTableViewCell.m
//  MXClassroom
//
//  Created by 你个LB on 16/9/9.
//  Copyright © 2016年 你个LB. All rights reserved.
//

#import "RecommendTableViewCell.h"

@implementation RecommendTableViewCell

/** 初始化方法 */
+ (instancetype)cellWithTableView:(UITableView *)tableView{
    static NSString * reuseIdentifier = @"identifier";
    RecommendTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (cell == nil) {
        // 创建cell
        cell = [[RecommendTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
    }
    return cell;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // 图标
        _iconView = [[UIImageView alloc] initWithFrame:CGRectMake(16, 17, 50, 50)];
        [self.contentView addSubview:_iconView];
        
        // 标题
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(_iconView.right + 18, 16, 100, 20)];
        _titleLabel.textColor = kColor_text_color;
        _titleLabel.font = [UIFont systemFontOfSize:14 weight:2];
        [self.contentView addSubview:_titleLabel];
        
        // 介绍
        _introductionLabel = [[UILabel alloc] initWithFrame:CGRectMake(_iconView.right + 18, _titleLabel.bottom , kScreen_width - _iconView.width - 3 * 17, 25)];
        _introductionLabel.bottom = _iconView.bottom;
        _introductionLabel.textColor = kColor_text_color;
        _introductionLabel.font = [UIFont systemFontOfSize:10];
        _introductionLabel.numberOfLines = 0;
        [self.contentView addSubview:_introductionLabel];
        
        // 收听人数
        _person_NumberLabel = [[UILabel alloc] initWithFrame:CGRectMake(kScreen_width - 100 - 17, 16, 100, 15)];
        _person_NumberLabel.bottom = _titleLabel.bottom;
        _person_NumberLabel.textColor = kColor_text_color;
        _person_NumberLabel.font = [UIFont systemFontOfSize:10];
        _person_NumberLabel.textAlignment = NSTextAlignmentRight;
        [self.contentView addSubview:_person_NumberLabel];
    }
    return self;
}

- (void)setRecommend:(RecommendModel *)recommend{
    if (_recommend != recommend) {
        _recommend = recommend;
        
        // 为控件设置数据
        _iconView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@", recommend.imageName]];
        
        _titleLabel.text = _recommend.title;
        
        _introductionLabel.text = _recommend.introduction;
        
        _person_NumberLabel.text = [NSString stringWithFormat:@"%@人在收听",_recommend.person_Number];
    }
}
@end
